<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
    <head>
        <meta charset="utf-8">

        <title>新增产品</title>
        <link th:href="@{~/css/styles.css}" rel="stylesheet" />
        <link rel="stylesheet" th:href="@{~/css/innerstyle.css}">
        <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
	    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
	    <link rel="stylesheet" type="text/css" th:href="@{~/DataTables/datatables.min.css}"/>
        <script type="text/javascript" th:src="@{~/DataTables/datatables.min.js}"></script>
        <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
        <script>
            $(function () {
                $("#add_button").click(function () {
                    $.ajax({
                        //几个参数需要注意一下
                        type: "Post",//方法类型
                        dataType: "json",//预期服务器返回的数据类型
                        url: "/product/add",//url
                        data: $('#productAddForm').serialize(),
                        success: function (data) {
                            if (data.statue == "0") {
                                alert("添加成功！");
                                window.location="/product/list";
                            } else if (data.statue=="1"){
                                alert(data.mes);
                            } else {
                                alert("添加失败...");
                            }
                        },
                        error: function () {
                            alert("时间格式不对！！");
                        }
                    });
                })
            })
        </script>
    </head>
    <body class="sb-nav-fixed">
    <div th:replace="bar::topbar"></div>
    <div id="layoutSidenav">
        <div th:replace="bar::#layoutSidenav_nav"></div>
        <div id="layoutSidenav_content">
        <div class="mainborder">

        <div class="row">
            <div>
                <h1>新增产品</h1>
            </div>
        </div>

        <form role="form" id="productAddForm">
            
            <div class="form-group">
                <label ><span style="color:red">*</span>产品名称</label>
                <input class="form-control" id = "productName" name="productName" type="text" placeholder="产品名称">
            </div>
            <div class="form-group">
                <label><span style="color:red">*</span>开始时间</label>
                <input class="form-control" id="createdDate" name="createdDate" type="text" placeholder="开始时间">
                <p style="color: red">时间格式为：2000/1/1</p>
            </div>
            <button type="button" id="add_button" class="btn btn-danger" style="float: right;">提交</button>
        </form>

        
    </div>
        </div>
    </div>
    

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
    <script th:src="@{~/js/scripts.js}"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.js" crossorigin="anonymous"></script>
    <script th:src="@{~/assets/demo/chart-area-demo.js}"></script>
    <script th:src="@{~/assets/demo/chart-bar-demo.js}"></script>
    <script src="https://cdn.jsdelivr.net/npm/simple-datatables@latest" crossorigin="anonymous"></script>
    <script th:src="@{~/js/datatables-simple-demo.js}"></script>
</body>
</html>
